var readline = require('readline-sync')
readline.setDefaultOptions({ prompt: '' })
var readline = readline.prompt

let q = parseInt(readline())
for (let i = 0; i < q; i++) {
  let nums = readline().split('').map((item) => parseInt(item))
  if (nums.length === 1) {
    if (nums[0] % 2 === 1) {
      console.log('-1')
    } else {
      console.log(nums[0])
    }
  } else {
    let flag = 0 // 初始变量
    for (let j = 0; j < nums.length; j++) {
      if (nums[j] % 2 === 0) {
        flag = 1
        let temp = nums[j]
        nums[j] = nums[nums.length - 1]
        nums[nums.length - 1] = temp
        break // 退出循环
      }
    }
    if (flag === 1) {
      if (nums[0] === 0) {
        for (let q = 1; q < nums.length; q++) {
          if (nums[q] !== 0) {
            nums[0] = nums[q]
            nums[q] = 0
            break
          }
        }
      }
      console.log(nums.join(''))
    } else {
      console.log('-1')
    }
  }
}